/**
 * @author vuhuynh
 */
var pager;
$(function(){

	
	
	
	 $.getJSON('http://localhost:8080/finalproject/adminViewAccountRequestJSON.json',
			{
			ajax:'true'
			},function(data)
			{
	
				$("#tableContent")
				.append(
						"<div class=\"pagination pagination-centered\" id=\"pageNavPosition\"></div>");
				var length =data.length;
				for(var i =0;i<length;i++)
				{	

					var content ="<tr>";					
					content+="<td class='cell-author hidden-phone hidden-tablet' style='text-align: center'>"+data[i].transactionId+"</td>";
					content+="<td class='cell-author hidden-phone hidden-tablet' style='text-align: center'>"+ data[i].accImpact.systemAccountType.typeName+"</td>";
					content+="<td class='cell-title' style='text-align: center'>"+ data[i].accImpact.accountLoginId+"</td>";
					content+="<td class='cell-title' style='text-align: center'>"+ data[i].accImpact.accountFirstName+ " " + data[i].accImpact.accountLastName + " " + data[i].accImpact.accountMidName +" </td>";
					content+="<td class='cell-title' style='text-align: center'>"+ data[i].accAffected.accountLoginId+"</td>";
					content+="<td class='cell-title' style='text-align: center'>"+ data[i].actionTransaction+"</td>";
					content+="<td class='cell-title' style='text-align: center'>"+ data[i].command+"</td>";
					content+="<td class='cell-title' style='text-align: center'>"+ data[i].dateTransaction+"</td>";
					if(data[i].systemStatus.statusId == 5){
						content+="<td class='cell-status hidden-phone hidden-tablet'><b class='due' style='background-color: green'>Complete</b></td>"
					}else if(data[i].systemStatus.statusId == 6){
						content+="<td class='cell-status hidden-phone hidden-tablet'><b class='due' style='background-color: red'>Reject</b></td>"
					}
					
					content+="</tr>";
					
					$("#request_transaction_by_account > tbody").append(content);
				}
				pager = new Pager('request_transaction_by_account', 15);
				pager.init();
				pager.showPageNav('pager', 'pageNavPosition');
				pager.showPage(1);
				//$('#request_transaction_by_account').DataTable();
			}	
	);
	 
	 $('#request_transaction_by_account').dataTable();
	
	
});
	